﻿using Styx.Common;
using Styx.CommonBot;
using Styx.TreeSharp;
using Action = Styx.TreeSharp.Action;

namespace TuanHA_Combat_Routine
{
    public partial class Classname
    {
        #region FrostRotation

        private static bool _aoEModeOn;

        private static Composite FrostRotation()
        {
            return new PrioritySelector(
                AutoTarget(),
                new Action(delegate
                    {
                        //Hold dps on Dungeon or Raid in No Combat
                        if (TreeRoot.Current.Name != "DungeonBuddy" &&
                            (InDungeon ||
                             InRaid) &&
                            !Me.Combat &&
                            Me.CurrentTarget != null &&
                            IsEnemy(Me.CurrentTarget) &&
                            !Me.CurrentTarget.IsTargetingMyPartyMember &&
                            !Me.CurrentTarget.IsTargetingMyRaidMember &&
                            !Me.CurrentTarget.IsTargetingMeOrPet)
                        {
                            return RunStatus.Success;
                        }

                        if (THSettings.Instance.AutoAoE &&
                            THSettings.Instance.UnittoStartAoE > 0 &&
                            !InArena &&
                            !InBattleground &&
                            CountEnemyNear(Me, 10) >= THSettings.Instance.UnittoStartAoE)
                        {
                            _aoEModeOn = true;
                        }
                        else
                        {
                            _aoEModeOn = false;
                        }

                        return RunStatus.Failure;
                    }),
                //But first, facing target
                //FacingTarget(),
                //Starting the movement right here
                MovementMoveStop(ret => Me.CurrentTarget, 3),
                //MovementMoveBehind(ret => Me.CurrentTarget),
                //MovementMoveToLoS(ret => Me.CurrentTarget),
                MovementMoveToMelee(ret => Me.CurrentTarget),
                //DPS Rotation Here
                //WriteTargetInfo(),
                IceboundFortitudeStun(),
                DesecratedGround(),
                //LichborneFear(),
                TargetMyPetTarget(),
                UseHealthstone(),
                UseBattleStandard(),
                //MindFreeze(),
                //DeathGripInterrupt(),
                IceboundFortitude(),
                LichborneHeal(),
                AntiMagicShell(),
                AntiMagicShellLichborne(),
                AntiMagicShellEnemy(),
                AntiMagicShellDebuff(),
                AntiMagicShellCaster(),
                AntiMagicZone(),
                AntiMagicZoneDebuff(),
                AntiMagicZoneCaster(),
                DeathGrip(),
                EmpowerRuneWeapon(),
                BloodFury(),
                BloodTap(),
                DarkSimulacrum(),
                DarkSimulacrumUse(),
                DeathsAdvance(),
                //Strangulate(),
                StrangulateLow(),
                DeathGrip(),
                DeathGripAsphyxiateHelpFriend(),
                DeathGripRemorselessWinter(),
                //Asphyxiate(),
                FrostPresenceSwap(),
                BloodPresenceSwap(),
                HornofWinterBuff(),
                RaiseAlly(),
                RaiseDead(),
                PillarofFrost(),
                new Decorator(
                    ret => !_aoEModeOn &&
                           Me.Inventory.Equipped.MainHand != null &&
                           Me.Inventory.Equipped.OffHand == null,
                    new PrioritySelector(
                        //WriteDebug("Doing TH Single"),
                        AttackASAP(),
                        DarkSuccor(),
                        SoulReaper(),
                        GorefiendsGraspAoE(),
                        //GorefiendsGraspInterrupt(),
                        GorefiendsGraspKiter(),
                        GorefiendsGraspMelee(),
                        IcyTouchDispel(),
                        RemorselessWinter(),
                        RemorselessWinterEnemyLowHP(),
                        RemorselessWinterEnemyNumber(),
                        RemorselessWinterBurst(),
                        DeathCoilHeal(),
                        ChainsofIce(),
                        ChainsofIceMelee(),
                        DeathandDecaySnare(),
                        DeathPact(),
                        DeathSiphon(),
                        Conversion(),
                        PlagueLeech(),
                        Outbreak(),
                        UnholyBlight(),
                        BloodBoilRoilingBlood(),
                        Pestilence(),
                        PlagueStrikeDebuff(),
                        HowlingBlastDebuff(),
                        IcyTouchDebuffFrost(),
                        ObliterateTHKM(),
                        NecroticStrikeStack(),
                        //NecroticStrikeDebuff(),
                        FrostStrikeTHCap(),
                        HowlingBlastProc(),
                        IcyTouchDispelLowPriority(),
                        ControlUndead(),
                        ControlUndeadUpdate(),
                        DeathStrike(),
                        ObliterateTH(),
                        FrostStrikeTH(),
                        HornofWinter(),
                        Presence(),
                        //DeathCoil(),
                        PathofFrost()
                        )),
                new Decorator(
                    ret => !_aoEModeOn &&
                           Me.Inventory.Equipped.MainHand != null &&
                           Me.Inventory.Equipped.OffHand != null,
                    new PrioritySelector(
                        //WriteDebug("Doing DW Single"),
                        DarkSuccor(),
                        SoulReaper(),
                        ChainsofIce(),
                        DeathPact(),
                        DeathSiphon(),
                        Conversion(),
                        PlagueLeech(),
                        Outbreak(),
                        UnholyBlight(),
                        BloodBoilRoilingBlood(),
                        Pestilence(),
                        NecroticStrikeStack(),
                        //NecroticStrikeDebuff(),
                        HowlingBlastDebuff(),
                        PlagueStrikeDebuff(),
                        FrostStrikeDWKM(),
                        FrostStrikeDWCap(),
                        HowlingBlastProc(),
                        ObliterateDWSimple(),
                        HowlingBlastDW(),
                        DeathandDecayDW(),
                        //ObliterateDWKM(),
                        //ObliterateDWRunicEmpowerment(),
                        //ObliterateDWBloodTap(),
                        //PlagueStrikeFrostDKKillUR(),
                        DeathStrike(),
                        FrostStrikeDW(),
                        HornofWinter(),
                        Presence(),
                        //DeathCoil(),
                        PathofFrost()
                        )),
                new Decorator(
                    ret => _aoEModeOn,
                    new PrioritySelector(
                        //WriteDebug("Doing AoE"),
                        DarkSuccor(),
                        SoulReaper(),
                        ChainsofIce(),
                        PlagueLeech(),
                        Outbreak(),
                        UnholyBlight(),
                        DeathandDecayAoE(),
                        BloodBoilRoilingBlood(),
                        Pestilence(),
                        HowlingBlastDebuff(),
                        PlagueStrikeDebuff(),
                        HowlingBlastAoE(),
                        FrostStrikeAoECap(),
                        DeathPact(),
                        DeathSiphon(),
                        Conversion(),
                        DeathStrike(),
                        PlagueStrikeFrostAoE(),
                        FrostStrikeAoELow(),
                        HornofWinter(),
                        Presence(),
                        PathofFrost()
                        )
                    )
                //RestRotation()
                );
        }

        #endregion
    }
}